<template>
  <el-dialog title="题目审核" :visible="isShowCheck" @close="close" width='420px'>
    <el-form ref="form" :model="form">
      <el-form-item>
        <el-radio v-model="form.chkState" :label="1">通过</el-radio>
        <el-radio v-model="form.chkState" :label="2">拒绝</el-radio>
      </el-form-item>
      <el-form-item>
        <el-input type="textarea" v-model="form.chkRemarks"></el-input>
      </el-form-item>
      <el-form-item>
        <el-row type="flex" justify="end">
          <el-button @click="close">取消</el-button>
          <el-button @click="check" type="primary">确认</el-button>
        </el-row>
      </el-form-item>
    </el-form>
  </el-dialog>
</template>

<script>
import { choiceCheck } from '@/api/hmmm/questions'
export default {
  props: {
    isShowCheck: {
      type: Boolean,
      required: true,
      default: false
    },
    CheckId: {
      type: Number,
      required: true,
      default: 1
    }
  },
  data () {
    return {
      form: {
        chkState: 1,
        chkRemarks: ''
      }
    }
  },
  methods: {
    close () {
      this.form = {
        chkState: 1,
        chkRemarks: ''
      }
      this.$emit('update:isShowCheck', false)
    },
    check () {
      this.$refs.form.validate(async (valid) => {
        if (valid) {
          if (this.form.chkRemarks) {
            await choiceCheck({ chkRemarks: this.form.chkRemarks, chkState: this.form.chkState, id: this.CheckId })
            this.$message.success('操作成功')
            this.close()
            this.$parent.list()
          } else {
            this.$message.warning('请输入审核意见')
            console.log('error submit!!')
            return false
          }
        }
      })
    }
  }
}
</script>

<style scoped lang='less'></style>
